package com.dqp.cslggroup.ConnectSever;

import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;
import java.util.Iterator;

public class SeverIP {
    /*
    * @Description: 获取服务器ip
    * @Param:
    * @return:
    * @Author: 董琴平
    * @Date: 2021/9/5
    */
    public static JSONObject getIp() {
        try {
            Connection.Response response;
            response = Jsoup.connect("https://www.cslggroup.top/ip.json")
                    .ignoreContentType(true)
                    .method(Connection.Method.GET)
                    .timeout(10000)
                    .execute();
            Document document = response.parse();
            return JSON.parseObject(document.text().replace(" ", ""));
        } catch (IOException | Error e) {
            e.printStackTrace();
            return null;
        }
    }

    /*
     * @Description: 获取服务器ip
     * @Param:
     * @return:
     * @Author: 董琴平
     * @Date: 2021/9/5
     */
    public static JSONObject getIpByGitee() {
        try {
            Connection.Response response;
            response = Jsoup.connect("http://dqp2375.gitee.io/imk/sever/ip.html")
                    .ignoreContentType(true)
                    .method(Connection.Method.GET)
                    .timeout(60000)
                    .execute();
            Document document = response.parse();
            return JSON.parseObject(document.text().replace(" ", ""));
        } catch (IOException | Error e) {
            e.printStackTrace();
            return null;
        }
    }


    public static String getDefvalueUrl() {
        return "https://www.cslggroup.top/imk";
    }
}
